package org.example.Controller;


import org.example.mapper.User2Mapper;
import org.example.pojo.User;
import org.example.pojo.User2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("user2")
public class User2Controller {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Autowired
    private User2Mapper user2Mapper;
//    @GetMapping("list")
//    public List<User> list() {
//        String sql = "select * from user";
//        List<User> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(User.class));
//        return list;
//    }

    @GetMapping("list2")
    public List<User2> list2() {
        return user2Mapper.findAll();
    }
}
